﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QuanLyTiemVang.DTO;

namespace QuanLyTiemVang.DAO
{
    class ChiTietBaoCaoTonDAO
    {
        private static QUANLYTIEMVANGEntities dbContext = new QUANLYTIEMVANGEntities();

        public static List<CHITIETBAOCAOTON> SelectAllChiTietBaoCaoTon()
        {
            var query = from d in dbContext.CHITIETBAOCAOTONs
                        select d;
            return query.ToList();
        }

        public static void Insert(CHITIETBAOCAOTON ctbct)
        {
            dbContext.CHITIETBAOCAOTONs.Add(ctbct);
            dbContext.SaveChanges();
        }

        public static void Update(CHITIETBAOCAOTON bct)
        {
            var query = dbContext.CHITIETBAOCAOTONs.Find(bct.MaChiTietBaoCaoTon);
            if (query != null)
            {
                query.MaBaoCaoTon = bct.MaBaoCaoTon;
                query.MaSanPham = bct.MaSanPham;
                query.SoLuongBan = bct.SoLuongBan;
                query.SoLuongMua = bct.SoLuongMua;
                query.TonCuoiKy = bct.TonCuoiKy;
                query.TonDauKy = bct.TonDauKy;
                dbContext.SaveChanges();
            }
        }
    }
}
